package com.shiguiwu.springmybatis.spring.configuration;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @description: Configuration的测试
 * @author: stone
 * @date: Created by 2021/9/15 14:17
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.spring.configuration
 */
public class ConfigurationTests {

    public static void main(String[] args) {
        // 没有@Configuration的注解获取的bean
        //AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(BeanConfig.class);
        //
        //SpringBean1 bean = context.getBean("springBean1",SpringBean1.class);
        //SpringBean1 bean2 = context.getBean("springBean2",SpringBean1.class);
        //BeanConfig bean1 = context.getBean(BeanConfig.class);
        //
        //System.out.println(bean);
        //System.out.println(bean2);
        //
        //System.out.println(bean == bean2);
        //System.out.println(bean1);
        //System.out.println("====================================================================");
        AnnotationConfigApplicationContext context1 = new AnnotationConfigApplicationContext(BeanAnnConfig.class);

        SpringBean1 bean3 = context1.getBean("springBean1",SpringBean1.class);
        SpringBean1 bean4 = context1.getBean("springBean2",SpringBean1.class);
        BeanAnnConfig bean5 = context1.getBean(BeanAnnConfig.class);

        System.out.println(bean3);
        System.out.println(bean4);

        System.out.println(bean4 == bean3);
        System.out.println(bean5);

    }

}
